package map;

public class Layer {

	private Region region;
	private Tile[][] tiles;
	private int zHeight;

	public Layer(Region r, int height) {
		region = r;
		zHeight = height;
		tiles = new Tile[100][100];
		for(int x = 0; x < 100; x++) {
			for(int y = 0; y < 100; y++) {
				if ((int) (Math.random()*4) == 1) {
					tiles[x][y] = new Tile("water", x, y);
				} else {
					switch ((int) (Math.random() * 3)) {
					case 0: 
						tiles[x][y] = new Tile("dirt", x, y);
						break;
					case 1:
						tiles[x][y] = new Tile("snow", x, y);
						break;
					case 2:
						tiles[x][y] = new Tile("grass", x, y);
						break;
					}
				}
			}
		}
	}

	public Tile[][] getTiles() {
		return tiles;	
	}

	public Region getRegion() {
		return region;
	}

	public Tile getTile(int x, int y) {
		return tiles[x][y];
	}

	public Tile getTileNorth(int x, int y) {
		return tiles[x][y+1];
	}

	public Tile getTileSouth(int x, int y) {
		return tiles[x][y-1];
	}

	public Tile getTileEast(int x, int y) {
		return tiles[x+1][y];
	}

	public Tile getTileWest(int x, int y) {
		return tiles[x-1][y];
	}

	public Tile getTileNorth(Tile t) {
		return tiles[t.getLocalX()][t.getLocalY()-1];
	}

	public Tile getTileSouth(Tile t) {
		return tiles[t.getLocalX()][t.getLocalY()+1];
	}

	public Tile getTileEast(Tile t) {
		return tiles[t.getLocalX()+1][t.getLocalY()];
	}

	public Tile getTileWest(Tile t) {
		return tiles[t.getLocalX()-1][t.getLocalY()];
	}

}
